﻿
@{
    Layout = null;
    ViewData["Title"] = "登录";
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@ViewData["Title"] - MicroConfig</title>

    <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
    <link rel="stylesheet" href="~/css/site.css" />

</head>
<body>

    <div class="container body-content">
        <div id="app">

            <h2>登录</h2>

            <form class="form-horizontal" style="max-width:800px;">
                <div class="form-group">
                    <label class="col-sm-2 control-label">账号</label>
                    <div class="col-sm-10">
                        <input class="form-control" v-model.trim="account" placeholder="新账号">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">密码</label>
                    <div class="col-sm-10">
                        <input type="password" class="form-control" v-model.trim="password" placeholder="新密码">
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="button" @@click="submit" class="btn btn-primary">确定</button>
                    </div>
                </div>
            </form>
        </div>
        <hr />
        <footer>
            <p>&copy; 2018 - MicroConfig</p>
        </footer>
    </div>
    <script src="~/lib/jquery/jquery.js"></script>
    <script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
    <script src="~/js/site.js" asp-append-version="true"></script>
    <script src="~/lib/vue/vue.js"></script>
    <script>
        var app = new Vue({
            el: "#app",
            data: {
                account: '',
                password: '',
            },
            methods: {
                submit: function () {
                    if (this.account == '') {
                        alert('账号不能为空');
                        return;
                    }
                    if (this.password == '') {
                        alert('密码不能为空');
                        return;
                    }
                    $.post('doLogin', { account: this.account, password: this.password }, function (flag) {
                        if (flag > 0) {
                            alert("登录成功");
                            location.href = '/';
                        } else {
                            alert("账号或密码错误");
                        }
                    });
                }
            }
        })
    </script>
</body>
</html>



